package com.joysuch.wwyt.edu.enums;

/**
 * 培训发布状态
 */
public enum TrainingPublishStatus {

    UN_PUBLISH(0, "待发布"), PUBLISH(1, "已发布");

    private int id;
    private String name;

    TrainingPublishStatus(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static TrainingPublishStatus findByName(String name) {
        TrainingPublishStatus[] values = TrainingPublishStatus.values();
        for (TrainingPublishStatus v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static TrainingPublishStatus findById(Integer level) {
        TrainingPublishStatus[] values = TrainingPublishStatus.values();
        for (TrainingPublishStatus v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Integer id) {
        if (id == null) {
            return null;
        }
        TrainingPublishStatus[] values = TrainingPublishStatus.values();
        for (TrainingPublishStatus v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
